package handler

import (
	"ebip/internel/domain"
	"ebip/internel/service"
	"ebip/internel/types"
	"ebip/pkg/ginl/wrap_gin"
	"github.com/gin-gonic/gin"
)

// @Description
// @Author 代码小学生王木木

type UserHandler struct {
	svc service.IUserSvc
	types.Res
}

func NewUserHandler(svc service.IUserSvc) *UserHandler {
	return &UserHandler{
		svc: svc,
		Res: types.Res{},
	}
}

// GenDefaultUser
//
//	@Description: 为系统生成一个默认的管理员账号
func (h *UserHandler) GenDefaultUser(ctx *gin.Context) (wrap_gin.Result, error) {
	defaultAdmin := domain.UserInfoDM{
		Username:    "admin",
		Description: "默认管理员",
		Password:    "wulinlin",
		Nickname:    "古希腊掌管Bug的神",
		Gender:      "男",
		IsAdmin:     1,
		CreateId:    -1,
	}
	user, err := h.svc.CreateUser(ctx, defaultAdmin)
	if err != nil {
		return h.ErrX(200), err
	}
	return h.SuccesJson(user), nil
}
func (h *UserHandler) CreateUser(ctx *gin.Context) {

}

func (h *UserHandler) GetUserInfo(ctx *gin.Context) (wrap_gin.Result, error) {
	// TODO X 实现查询用户信息接口
	mockRes := types.UserInfoResp{
		Roles:        []string{"admin"},
		Introduction: "古希腊掌管bug的神",
		Avatar:       "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif",
		Name:         "Admin",
	}
	return h.SuccesJson(mockRes), nil
}

//func (h *UserHandler) GetUserInfo(ctx *gin.Context) {
//
//}
